#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
using namespace std;
class Solution {
public:
    string singlemul(string num, char ch, int n)
    {
        string sum;
        for (int j = 0; j < n; j++)
        {
            sum += '0';
        }
        int carry = 0;
        int i = num.size();
        for (int j = 0; j < i; j++)
        {
            int result = (ch - '0') * (num[i - j - 1] - '0') + carry;
            carry = result / 10;
            if (result > 9)
            {
                result %= 10;
            }
            sum += result + '0';
        }
        if (carry > 0)
        {
            sum += carry + '0';
        }
        reverse(sum.begin(), sum.end());
        return sum;
    }
    string addition(string num1, string num2)
    {
        int i = num1.size() - 1;
        int j = num2.size() - 1;
        int carry = 0;
        int n1, n2, add;
        string num;
        while (i >= 0 || j >= 0)
        {
            n1 = i < 0 ? 0 : num1[i--] - '0';
            n2 = j < 0 ? 0 : num2[j--] - '0';
            add = n1 + n2 + carry;
            carry = add / 10;
            if (add > 9)
            {
                add %= 10;
            }
            num += add + '0';
        }
        if (carry > 0)
        {
            num += carry + '0';
        }
        reverse(num.begin(), num.end());
        return num;
    }
    string multiply(string num1, string num2) {
        size_t i = num2.size();
        string result("0");
        if (num1 == "0" || num2 == "0")
        {
            return result;
        }
        for (int j = 0; j < i; j++)
        {
            string s = singlemul(num1, num2[i - j - 1], j);
            result = addition(result, s);
        }
        return result;
    }
};
int main()
{
    string num1 = "999";
    string num2 = "888";
    Solution s;
    cout << s.multiply(num1, num2) << endl;
    return 0;
}